﻿package frEngine.shader.filters.fragmentFilters
{
    import __AS3__.vec.*;
    import frEngine.shader.*;
    import frEngine.shader.filters.*;
    import frEngine.shader.registType.*;

    public class ColorFilter extends FragmentFilter
    {
        public var colorValue:Vector.<Number>;

        public function ColorFilter(param1:Number, param2:Number, param3:Number, param4:Number = 1)
        {
            this.colorValue = new Vector.<Number>(4, true);
            this.colorValue[0] = param1;
            this.colorValue[1] = param2;
            this.colorValue[2] = param3;
            this.colorValue[3] = param4;
            return;
        }// end function

        override public function setRegisterParams(param1:Program3dRegisterInstance) : void
        {
            param1.getParamByName(FilterName.COLOR, false).value = this.colorValue;
            param1.getParamByName("{ColorOffset}", false).value = this.colorOffsetValue;
            return;
        }// end function

        override public function get programeId() : String
        {
            return "color0";
        }// end function

        override public function clone() : FilterBase
        {
            return this;
        }// end function

        public function set colorR(param1:Number) : void
        {
            this.colorValue[0] = param1;
            return;
        }// end function

        public function set colorG(param1:Number) : void
        {
            this.colorValue[1] = param1;
            return;
        }// end function

        public function set colorB(param1:Number) : void
        {
            this.colorValue[2] = param1;
            return;
        }// end function

        public function set alpha(param1:Number) : void
        {
            this.colorValue[3] = param1;
            return;
        }// end function

        override public function createVertexCode(param1:Program3dRegisterInstance, param2:int) : String
        {
            return "";
        }// end function

        override public function createFragmentColor(param1:Program3dRegisterInstance, param2:Boolean) : String
        {
            var _loc_3:* = new Array();
            _loc_3.push(new ToBuilderInfo("fc0", FilterName.COLOR, false, 1, this.colorValue));
            _loc_3.push(new ToBuilderInfo("fc1", "{ColorOffset}", false, 1, colorOffsetValue));
            var _loc_4:String = "";
            var _loc_5:* = param1.getParamByName(FilterName.V_ColorOffset, false);
            if (_loc_5)
            {
                _loc_4 = "add           {output}        fc0      " + _loc_5.paramName + "    \t\n";
            }
            else
            {
                _loc_4 = "mov           {output}        fc0\t\t\t\t\t\t\t\t\t\n";
            }
            _loc_4 = _loc_4 + "mul         {output}.xyz       {output}.xyz fc1.w\t\t\n";
            _loc_4 = _loc_4 + "mul         {output}       \t {output}  \tfc1\t\t\t\n";
            _loc_4 = param1.toBuild(_loc_4, _loc_3);
            return _loc_4;
        }// end function

    }
}
